cmake_minimum_required(VERSION 3.5)
project(xunjian_robot)

# Default to C99
if(NOT CMAKE_C_STANDARD)
  set(CMAKE_C_STANDARD 99)
endif()

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(nav2_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(OpenCV REQUIRED)
find_package(autopatrol_interfaces REQUIRED)  # 添加自定义接口包

# 查找espeak库
find_package(PkgConfig REQUIRED)
pkg_check_modules(ESPEAK REQUIRED espeak-ng)

# 创建可执行文件
add_executable(xunjian_robot src/PatrolRobot.cpp)
add_executable(speaker_node src/speaker.cpp)

# 为 xunjian_robot 配置依赖
ament_target_dependencies(xunjian_robot
  rclcpp
  rclcpp_action
  nav2_msgs
  geometry_msgs
  sensor_msgs
  cv_bridge
  autopatrol_interfaces
)
# 为 speaker_node 配置依赖
ament_target_dependencies(speaker_node
  rclcpp
  autopatrol_interfaces
)

# 链接库文件
target_link_libraries(xunjian_robot
  ${OpenCV_LIBRARIES}
)

target_link_libraries(speaker_node
  ${ESPEAK_LIBRARIES}
)

# 包含目录
target_include_directories(xunjian_robot PRIVATE
  ${OpenCV_INCLUDE_DIRS}
)

target_include_directories(speaker_node PRIVATE
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>
  ${ESPEAK_INCLUDE_DIRS}
)

# 安装可执行文件
install(TARGETS
  xunjian_robot
  speaker_node
  DESTINATION lib/${PROJECT_NAME}
)

# 安装配置文件
install(DIRECTORY
  config/
  DESTINATION share/${PROJECT_NAME}/config
)

# 安装launch文件
install(DIRECTORY
  launch/
  DESTINATION share/${PROJECT_NAME}/launch
)

# 安装头文件目录
install(DIRECTORY
  include
  DESTINATION include
)

# 测试配置
if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # uncomment the line when a copyright and license is not present in all source files
  #set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # uncomment the line when this package is not in a git repo
  #set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()




